#!/user/bin/env python3
# -*- coding: utf-8 -*-
"""
--------------------------------------
    Author:     JiChao_Song
    Date  :     2021/3/10 8:42
    Desc  :
--------------------------------------
"""
from bson import json_util

from application import mongo


class Product(mongo.Document):
    """
    产品
    """

    name = mongo.StringField(require = True, unique = True)
    remark = mongo.StringField()

    def to_json(self):
        return {
            '_id': eval(json_util.dumps(self.id)),
            'name': self.name,
            'remark': self.remark,
        }


class ProductVersion(mongo.Document):
    """
    产品版本原型
    """

    product = mongo.StringField(require = True)  # 产品
    version = mongo.StringField()  # 版本
    prototype = mongo.StringField()  # 原型地址
    remark = mongo.StringField()  # 备注
    person = mongo.StringField()  # 负责人

    def to_json(self):
        return {
            '_id': eval(json_util.dumps(self.id)),
            'product': self.product,
            'version': self.version,
            'prototype': self.prototype,
            'remark': self.remark,
            'person': self.person,
        }
